package or.bhavani.wordhistogram;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.HashMap;

public class HistogramWithmap {

	private HashMap< String, Integer> wordCount = new HashMap<String, Integer>();

	public HashMap map(){
		
		try {

			BufferedReader read = new BufferedReader(new FileReader("/Users/bhavaniyarlagadda/Documents/Durga/Alogorithms/Alogorithms/src/or/bhavani/wordhistogram/durga"));

			String s;			
			System.out.println("Reading file  wordcount");

			while ((s = read.readLine()) != null) {

			if(	wordCount.containsKey(s)){
					wordCount.put(s, wordCount.get(s) + 1);
					
				}
				else{
					wordCount.put(s, 1);

				}
			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
		
		return wordCount;
		
	}
	public static void main(String args[]) {
		HistogramWithmap histogram = new HistogramWithmap();
	
		System.out.println(histogram.map());
	}
}
